import {Component, Input, OnInit} from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { DomSanitizer } from "@angular/platform-browser";
declare var $:  any;
@Component({
  selector: 'app-menu',
  templateUrl: './menu.component.html',
  styleUrls: ['./menu.component.css']
})
export class MenuComponent implements OnInit{
  menuMessage : string;
  @Input()
  menuList:Array<any>;
  addressUrl :string =  location.pathname;//本地地址路径
  public numberOne:number;
  public numberTwo:number;

  constructor(private http: HttpClient,private sanitizer: DomSanitizer) {
    // this.http.get('api/menu.json').subscribe(data => {
    //   console.log(data);
    //   if(data['result'].resultCode = "00000000"){
    //     this.menuList = data['menuList'];
    //   }else{
    //     alert("失败！")
    //   }
    // });

  }
  ngOnInit() {

    if(this.menuList==null){
      this.http.get('api/menu.json').subscribe(data => {
        if(data['result'].resultCode = "00000000"){
          this.menuList = data['menuList'];
        }else{
          alert("失败！")
        }

      });
    }else{
      this.menuList = this.menuList;
    }

  }
  colorTwo(a){
    this.numberTwo = a;
  }
  colorOne(q){
    this.numberOne = q;
    this.numberTwo=undefined;
  }



}




